package edu.com.wjt219971332.service.impl;

import edu.com.wjt219971332.entity.Matchup;
import edu.com.wjt219971332.dao.MatchupDao;
import edu.com.wjt219971332.service.MatchupService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.PageRequest;

import javax.annotation.Resource;
import java.util.List;

/**
 * (Matchup)表服务实现类
 *
 * @author makejava
 * @since 2023-12-29 09:28:15
 */
@Service
public class MatchupServiceImpl implements MatchupService {
    @Autowired
    private MatchupDao matchupDao;


    @Override
    public Matchup queryById(Integer matchupid) {
        return this.matchupDao.queryById(matchupid);
    }


    @Override
    public Page<Matchup> queryByPage(Matchup matchup, PageRequest pageRequest) {
        long total = this.matchupDao.count(matchup);
        return new PageImpl<>(this.matchupDao.queryAllByLimit(matchup, pageRequest), pageRequest, total);
    }


    @Override
    public int insert(Matchup matchup) {
        return this.matchupDao.insert(matchup);
    }


    @Override
    public int update(Matchup matchup) {
        return this.matchupDao.update(matchup);
    }


    @Override
    public boolean deleteById(Integer matchupid) {
        return this.matchupDao.deleteById(matchupid) > 0;
    }

    @Override
    public List<Matchup> queryByusername(String name) {
        return this.matchupDao.queryByusername(name);
    }
}
